<?php
function yinli($y,$m,$d,$h=null){  //阳历转阴历
    header("Content-Type:text/html;charset=utf-8");

    $lunar = new \Library\Lunar();
    $month = $lunar->convertSolarToLunar($y,$m,$d);//将阳历转换为阴历
    $data = $lunar->getLeapMonth($month[0]);//判断闰月
    cookie('runyue',$data);

    if($y>=1930&&$y<2041){
        $jieqi=$lunar->meJieqi($y,$m,$d,$h);
    }else{
        if(($y%4==0&&$m>1)||($y%4==1&&$m<2))$d+=1;//闰年加1天
        $jieqi=$lunar->getJieQi($y,$m,$d);
    }

    cookie('jieqi',$jieqi['name1']);
    cookie('jieqi2',$jieqi['name2']);
    $month['jieqi']=$jieqi;
    return $month;
}
function yangli($y,$m,$d){//阴历转阳历
    $lunar = new \Library\Lunar();
    $month = $lunar->convertLunarToSolar($y,$m,$d);//将阳历转换为阴历
    return $month;
}

function jieqi($ymd){//计算节气的日期
    $y=mb_substr($ymd,0,4);
    $m=mb_substr($ymd,5,2); //月
    $d=mb_substr($ymd,8,2);//日
    header("Content-Type:text/html;charset=utf-8");
    $lunar = new \Library\Lunar();
    $jieqi=$lunar->getJieQi($y,$m,$d);
    return $jieqi['name1'];
}
function jieqiapi($ymd,$jieqi){//获取节气的具体时间
    if($jieqi=='冬至'){$ymd-=1;}

    $arrjeiqi=array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨",
        "立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑",
        "白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至");
    $key=array_search($jieqi,$arrjeiqi);
    $arrjeiqix=array("xiaohan","dahan","lichun","yushui","jingzhe","chunfen","qingming","guyu",
        "lixia","xiaoman","mangzhong","xiazhi","xiaoshu","dashu","liqiu","chushu",
        "bailu","qiufen","hanlu","shuangjiang","lidong","xiaoxue","daxue","dongzhi");

    $arr=M()->query("select * from tb_24jieqi where year='{$ymd}'");

    cookie('24jieqi',$arr[0][$arrjeiqix[$key]]);
    $data=mb_substr($arr[0][$arrjeiqix[$key]],12,5,'utf-8');
   if($data){
       return $data;
   }else{
       return '11:55';
   }

}
//恋爱桃花运
function LAtaohua($arrtaohua,$ymd){
    $y=mb_substr($ymd,0,4);
    $m=mb_substr($ymd,5,2); //月
    $d=mb_substr($ymd,8,2);//日
    $taohuaNum=count($arrtaohua);
    $forNum=($y+$m+$d)%9+$taohuaNum<9?($y+$m+$d)%9+$taohuaNum:9;
    if($forNum<4)$forNum+=3;
    $hidetaohua=array();
    for($i=1;$i<=$forNum;$i++){
        if($i!=$arrtaohua[0]['id']){
            $arr=M()->query("select * from tb_taohua_luck where id={$i}");
            $hidetaohua=array_merge($hidetaohua,$arr);
        }
    }
    $GLOBALS['hidetaohua']=$hidetaohua;

    $thmjarr=[[
        '碧色碧色','a、你具有温和亲切、善解人意的特质，只要心有所属，就不会感情出轨；但是你不懂得婉拒别人的追求，快乐的恋情便会衍生出许多牵扯不清的纠纷；唯有学会负责与解决问题，感情才会更美满。“庚”年容易遇到心仪的对象或有喜事发生。今年就是“庚寅”年，桃花一定会很旺！','
                   b、你是一个内心渴望与人并驾齐驱，不甘落于人后。正因为这样，反而让你给人一种独断独行的感觉，凡事靠自己，不愿藉助他人之手，很有自知之明，临事果决，光明磊落，表里如一，同时也有六亲缘薄的倾向，男女皆不宜早婚。配偶年纪差距不会太大，甚至有同岁的可能。属于晚婚型的结构，性格上除了直率外，尚有点心高气傲。您会守住或绑住你的配偶，而你却并非是个温柔体贴的好伴侣，所以婚姻生活易起冲突！'
    ],[
      '绿色紫色','a、你的感情官真挚热烈，全心全意，不容许背叛。对于感情你是很有想法的人，有时会拘泥在固执想法里而不容易妥协，使口舌争执不断发生；不妨试着多了解对方的用心你会更快乐。在“乙”年容易遇到心仪的对象或有喜事发生。','
                 b、你品性端正，正大光明，心地善良，客观理性，知礼守法，重视纪律法规；正官为忌时，做事按步就班、循序渐进、却流于刻板谨慎与墨守成规，同时也缺乏耐心，做事往往虎头蛇尾，太过于空洞刻板，缺乏先知之明。因此在择偶时，往往会选择年纪小一点，却也往往是因相亲而结婚。婚姻运很不错，拥有幸福美满的家庭生活可能性很高。'
    ],[
       '紫色绿色','a、你对于感情的态度细腻谨慎，追求和谐默契，只有在确定感情后，才会放下矜持，以炽热的态度去表达爱意！在感情的付出上易消极，容易把话闷在心里面，应该要主动付出与关怀，才不会错失良机哦！“壬”年容易遇到心仪的对象或有喜事发生。','
                  b、你的为人慷慨豪迈，聪明圆滑，机智敏锐，淡泊名利，豪爽侠义，乐于助人，不喜欢虚伪，为人讲义气，但也风流多情，出手也很大方，见义不惜财，所以人缘大都还不错。'
    ],[
       '白色黑色','a、神秘忧郁、惹人怜爱、重情重欲的人，容易受异性垂青或恋慕，若不懂得挑选伴侣、控制情欲，情路便会波折不断。因此，请试着调整心态，人并不完美，细水长流的爱才是更美好的。另外，“戊”年容易遇到心仪的对象或有喜事发生。','
                  b、你的为人比较偏激也喜欢冒险，具有高昂的斗志及果断力，济弱扶倾，锄强扶弱，可是也刚愎自用。本身个性太过于急躁如火，做事往往欠缺深思考虑，是独断独行的性格，主观重，不会随意听取别人的意见，思想上较为反传统，所以配偶有年龄差距较大的倾向。最好伴侣年龄有差距，可调整自己属性与变动，让自己感情婚姻生活变得较为充实；婚前婚后，皆能散发吸引异性的丰采，一般有较多接触异性的机会，即使在婚后，亦会有来自感情方面的困扰。'
    ],[
       '碧色紫色','a、在爱情国度里，你的感情率性真挚，希望得到完全的遵从及宠爱，比较不会放下身段去委曲求全。若想使感情更顺利，你要试着多主动付出关心，而不是单方面要求对方。在“己”年你容易遇到心仪的对象或有喜事发生。','
                  b、你给人的感觉就是一个才华横溢的人，实际上你也是在没有拘束地展露自己，表现在外的才华，性格属于开朗又外向多情，活泼乐观，博学多能，多才多艺，聪明睿智，清逸秀丽，领悟力很强。聪明又反应快，很想要超越自我和别人的欲望，也喜欢他人的肯定与掌声，最讨厌世俗礼法的约束，不喜欢长辈的批评，因而我行我素，只要我喜欢有什么不可以，也因为这种强烈的竞争心态，如果另一半与自己年纪相近，只怕吵吵闹闹，永无宁日。虽然你充满真诚，能够舍己从人，但在社会上欠圆通；喜怒哀乐易行于外，心中有话藏不住，作事喜欢高谈阔论，如果经营事业往往或对事物的看法抱持过于乐观的态度而导致失败。其怎择偶对象，特别喜欢年龄差距大的人。通常都是不被亲友看好的婚姻，甚至周遭人也会有反对的声音。由于情绪起伏过大，所以婚姻感情的困扰亦多，而太早结婚恐怕婚姻很难保住。'
    ],[
       '中部白色','a、你的感情执着内敛，宅心仁厚，但却不善于表达感情，对于爱情的细腻度及敏感度又稍嫌不够，因此感情生活里常少了一点多彩多姿的情调；不妨经常绽放笑容、培养浪漫情怀，才能更讨人喜欢。“癸”年容易遇到心仪的对象或有喜事发生。','
                 b、你的为人比较偏激也喜欢冒险，具有高昂的斗志及果断力，济弱扶倾，锄强扶弱，可是也刚愎自用。本身个性太过于急躁如火，做事往往欠缺深思考虑，是独断独行的性格，主观重，不会随意听取别人的意见，思想上较为反传统，所以配偶有年龄差距较大的倾向。最好丈夫年龄有差距，可调整自己属性与变动，让自己感情婚姻生活变得较为充实；婚前婚后，皆能散发吸引异性的丰采，一般有较多接触异性的机会，即使在婚后，亦会有来自感情方面的困扰。'
    ],[
       '绿色白色','a、你的感情官真挚热烈，全心全意，不容许背叛。对于感情你是很有想法的人，有时会拘泥在固执想法里而不容易妥协，使口舌争执不断发生；不妨试着多了解对方的用心你会更快乐。在“乙”年容易遇到心仪的对象或有喜事发生。','
                 b、你的为人慷慨豪迈，聪明圆滑，机智敏锐，淡泊名利，豪爽侠义，乐于助人，不喜欢虚伪，为人讲义气，但也风流多情，出手也很大方，见义不惜财，所以人缘大都还不错。'
    ],[
        '碧色白色','a、在爱情国度里，你的感情率性真挚，希望得到完全的遵从及宠爱，比较不会放下身段去委曲求全。若想使感情更顺利，你要试着多主动付出关心，而不是单方面要求对方。在“己”年你容易遇到心仪的对象或有喜事发生。','
                  b、你拥有较为高雅的品味，气质比较出众有爱心，重视内在与内涵，很有人情味，爱好面子有自尊。只是凡事出一张嘴，不想自已动手，只想别人代劳。容易找到心地比较好的另一伴，且对方对自己是容易付出的类型。配偶仁慈善良，聪颖敦厚，气质高尚优雅，日主弱者尤佳。依赖性强的你容易导致无主见，显示出来的却是平安而有福气，因为压力减少易流于懒惰，容易找年龄差距比自身小的配偶，且心中永远存在着不能告诉配偶的秘密。本人自尊心很强，在意的是眼前的事情，所以会有斤斤计较之毛病，十分重视颜面及家庭的形象，追求财富的心虽然很强烈，却不形之于色。意志力稍嫌薄弱，与先生之间总觉得有一层难以突破的薄膜，也无法满足先生所给予的一切！'
    ]];
    $mjNum=($y+$m+$d)%7;
    $GLOBALS['thmjarr']=$thmjarr[$mjNum];

    $dateYM=date('Ym');
    if(S($ymd.'thys'.$dateYM.'2020')==''){//桃花三月运势计算
        $date=intval(date('m'));
        $datex=$date+1<=12?$date+1:1;
        $datey=$datex+1<12?$datex+1:1;
        $thysarr=array($date=>array(),$datex=>array(),$datey=>array());
        $direction=array('正北','正南','正西','正东','西北','西南','东北','东南');
        foreach($thysarr as $key=>$value){
            shuffle($hidetaohua);
            $data=mt_rand(1,count($hidetaohua));
            for($i=0;$i<$data;$i++){
                $fxnumx=mt_rand(0,3);$fxnumy=mt_rand(4,7);
                $directionStr=$direction[$fxnumx].$direction[$fxnumy];
                $hidetaohua[$i]['direction']=$directionStr;
                $index=mt_rand(30,95);
                $hidetaohua[$i]['index']=$index.'%';
                $hidetaohua[$i]['text']=null;
                $hidetaohua[$i]['xiangzheng']=null;
                $hidetaohua[$i]['yingxiang']=null;
                array_push($thysarr[$key],$hidetaohua[$i]);
            }
        }
        S($ymd.'thys'.$dateYM.'2020',$thysarr,2592000);
    }

    $thysarr=S($ymd.'thys'.$dateYM.'2020');
    //dump($thysarr);exit;
    $GLOBALS['thysarr']=$thysarr;
}

//八字精批
function liunian($bznianzhu){//流年数据
    if(S('tb_liunian'.$bznianzhu)){
        $liunian=S('tb_liunian'.$bznianzhu);
    }else{
        $liunian=M()->query("select * from tb_liunian where name='{$bznianzhu}'");
        S('tb_liunian'.$bznianzhu,$liunian,86400);
    }
    $GLOBALS['liunian']=$liunian[0];
}
function fortune($shengxiao,$bzrizhu,$yearNum=null){
    $y=mb_substr(cookie('zymd'),0,4);//年
    $y+=$yearNum-1;
    $data=$y%5;
    if($data==0){
        $data=5;
    }

    if(S('tb_fortune'.$shengxiao)){
        $fortune=S('tb_fortune'.$shengxiao);
    }else{
        $fortune=M()->query("select * from tb_fortune where name='{$shengxiao}'");
        S('tb_fortune'.$shengxiao,$fortune,86400);
    }

    $GLOBALS['shortcoming']=$fortune[0]['shortcoming'];
    $GLOBALS['fortune']=$fortune[0]['fortune'.$data];
    $GLOBALS['congenital']=$fortune[0]['congenital'];
    $GLOBALS['be_careful']=$fortune[0]['be_careful'];
    $Arr['be_careful1']=$fortune[0]['be_careful1'];

    $lovefenxi=M()->query("select lovefenxi,lovefenxi1,lovenum0,lovenum1,lovenum2 from tb_fortune where namegz='".mb_substr($bzrizhu,0,1,'utf-8')."'");
    if(cookie('zsex')==1){
        $GLOBALS['lovefenxi']=$lovefenxi[0]['lovefenxi1'];
    }else{
        $GLOBALS['lovefenxi']=$lovefenxi[0]['lovefenxi'];
    }

    $data=$y%3;
    $thnumber=explode(',',$lovefenxi[0]['lovenum'.$data]);
    $arrtaohua=array();
    for($i=0;$i<count($thnumber);$i++){
        $arr=M()->query("select * from tb_taohua_luck where id={$thnumber[$i]}");
        $arrtaohua=array_merge($arrtaohua,$arr);
    }
    $GLOBALS['arrtaohua']=$arrtaohua;

    $shengxiaosh=M()->query("select name,bmf,image0,namesh1,image1,namesh2,image2,dizhi1,dizhi2 from tb_fortune where name='{$shengxiao}'");
    $GLOBALS['shengxiaosh']=$shengxiaosh[0];
    return $Arr;
}
function wuxing_healthy($wuxing){
     if(S('tb_wuxing_healthy'.$wuxing)){
         $arrdata=S('tb_wuxing_healthy'.$wuxing);
     }else{
         $arrdata=M()->query("select * from tb_wuxing_healthy where name='{$wuxing}'");
         S('tb_wuxing_healthy'.$wuxing,$arrdata,86400);
     }
     $GLOBALS['wuxing']=$arrdata[0];
}

//八字合婚
function bzhehun($zymd,$fymd){
    $ymdArr=explode('-',$zymd);
    $fymdArr=explode('-',$fymd);
    $year=$ymdArr[0];
    $fyear=$fymdArr[0];
    $dataNum=$ymdArr[0]+$ymdArr[1]+$ymdArr[2]+$fymdArr[0]+$fymdArr[1]+$fymdArr[2];
    $data=$dataNum%6?$dataNum%6:6;
    $myarr=M()->query("select * from tb_bzhehun where id={$data}");
    $position=array('东','南','西','北');
    $positionx=$position[$year%3];
    $positiony=$position[$fyear%3];
    array_push($myarr[0],$positionx,$positiony);
    $cgysarr=M()->query("select cgys from tb_bzhehun where id='".cookie('cgysnum')."'");
    $myarr[0]['cgys']=$cgysarr[0]['cgys'];
    $Arr['myarr']=$myarr[0];
    $mgjudge=$myarr[0]['mgjudge'];

    //命中注定
    //$data=($dataNum%10)?$dataNum%10:10;
    $mzzd=M()->query("select mzzd from tb_bzhehun where mgjudge={$mgjudge}");
    $countNUm=count($mzzd);
    $keyNum=$dataNum%$countNUm;
    $Arr['mzzd']=$mzzd[$keyNum]['mzzd'];

    //相扶相旺
    $datax=($year%3)?$year%3:3;
    $datay=(($fymdArr[0]+$fymdArr[1]+$fymdArr[2])%3);if($datay==0){$datay=3;}
    $xfxwx=M()->query("select xfxw_man from tb_bzhehun where id={$datax}");
    $xfxwy=M()->query("select xfxw_woman from tb_bzhehun where id={$datay}");
    $xfxw=array_merge($xfxwx[0],$xfxwy[0]);
    $Arr['xfxw']=$xfxw;
    return $Arr;
}
function bzhh_fortune($bzrizhu,$fbzrizhu){
    $y=mb_substr(cookie('zymd'),0,4);//年
    $fy=mb_substr(cookie('fymd'),0,4);

    $lovefenxi=M()->query("select * from tb_fortune where namegz='".mb_substr($bzrizhu,0,1,'utf-8')."'");
    $flovefenxi=M()->query("select * from tb_fortune where namegz='".mb_substr($fbzrizhu,0,1,'utf-8')."'");
    $data=$y%3;
    $fdata=$fy%3;
    $thnumber=explode(',',$lovefenxi[0]['lovenum'.$data]);
    $fthnumber=explode(',',$flovefenxi[0]['lovenum'.$fdata]);
    if(preg_match("/[6]/",$thnumber[0])){ $datax=0;}else{$datax=1;}
    if(preg_match("/[6]/",$thnumber[0])){ $datay=0;}else{$datay=1;}
    if($datax==0&&$datay==0){
        $data=4;
    }else if($datax==1&&$datay==0){
        $data=3;
    }else if($datax==0&&$datay==1){
        $data=2;
    }else{
        $data=1;
    }
    cookie('cgysnum',$data,46000);
}
function jiatingms($bznianzhu,$zymd,$fymd){
    $ymdArr=explode('-',$zymd);
    $fymdArr=explode('-',$fymd);
    $dataNum=$ymdArr[0]+$ymdArr[1]+$ymdArr[2]+$fymdArr[0]+$fymdArr[1]+$fymdArr[2];

    $y=mb_substr(cookie('zymd'),0,4);//年
    $jtmsx=M()->query("select jtms from tb_wedlock where name='{$bznianzhu}'");
    $data=($dataNum%7)?$dataNum%7:7;
    $jtmsy=M()->query("select jtms from tb_bzhehun where id={$data}");
    $jtmsarr=array();
    array_push($jtmsarr,$jtmsx[0]['jtms'],$jtmsy[0]['jtms']);
    $GLOBALS['jtmsarr']=$jtmsarr;
}
//流年运程
function lnyuncheng($zymd,$dayun,$dayunss){
    $y=mb_substr($zymd,0,4);$datayear=date('Y')-$y;
    $GLOBALS['age']=$datayear;
    if($datayear<$dayun+11){$data=0;}else if($datayear<$dayun+21){$data=1;}else if($datayear<$dayun+31){$data=2;
    }else if($datayear<$dayun+41){$data=3;}else if($datayear<$dayun+51){$data=4;
    }else if($datayear<$dayun+61){$data=5;}else if($datayear<$dayun+71){$data=6;}else{$data=7;}
    $arrlnyc=M()->query("select * from tb_lnyuncheng where name='{$dayunss[$data]}'");
    $GLOBALS['lnyuncheng']=$arrlnyc[0];
    $GLOBALS['datacolor']=$data;
}
//流年运程2019
function lnyuncheng2019($zymd,$dayun,$dayunss,$constellation,$hour,$yearNum=null){
    $y=mb_substr($zymd,0,4);$m=mb_substr($zymd,5,2);$d=mb_substr($zymd,8,2);
    $datayear=date('Y')-$y;
    $ln2019['age']=$datayear;
    if($datayear<$dayun+11){$data=0;}else if($datayear<$dayun+21){$data=1;}else if($datayear<$dayun+31){$data=2;
    }else if($datayear<$dayun+41){$data=3;}else if($datayear<$dayun+51){$data=4;
    }else if($datayear<$dayun+61){$data=5;}else if($datayear<$dayun+71){$data=6;}else{$data=7;}
    $arrlnyc=M()->query("select name,dianping from tb_lnyuncheng where name='{$dayunss[$data]}'");
    $ln2019['lnyuncheng']=$arrlnyc[0];
    $ln2019['datacolor']=$data;

    if($yearNum){
        $idNUm=($yearNum%12)+1;
        $cArr=M()->query("select id,yunshi from tb_constellation_2019 where id='{$idNUm}'");
    }else{
        $cArr=M()->query("select id,yunshi from tb_constellation_2019 where star='{$constellation}'");
    }
    $ln2019['yunshi']=$cArr[0]['yunshi'];
    $cid=$cArr[0]['id'];
    for($i=1;$i<=5;$i++){
        $cid+=1;if($cid>10)$cid-=10;
        if($i==1){$cArr=M()->query("select id,caiyun from tb_constellation_2019 where id=$cid");$ln2019['caiyun']=$cArr[0]['caiyun'];}
        if($i==2){$cArr=M()->query("select id,shiye from tb_constellation_2019 where id=$cid");$ln2019['shiye']=$cArr[0]['shiye'];}
        if($i==3){$cArr=M()->query("select id,aiqing from tb_constellation_2019 where id=$cid");$ln2019['aiqing']=$cArr[0]['aiqing'];}
        if($i==4){$cArr=M()->query("select id,jiankang from tb_constellation_2019 where id=$cid");$ln2019['jiankang']=$cArr[0]['jiankang'];}
        if($i==5){$cArr=M()->query("select id,xueye from tb_constellation_2019 where id=$cid");$ln2019['xueye']=$cArr[0]['xueye'];}
    }

    $yjNumber=($y+$m+$d-$hour+1+$yearNum)%10;
    $monthArr=array();
    for($i=1;$i<=12;$i++){
        $yjNumber+=2;
        if($yjNumber>10)$yjNumber-=10;
        $data='month'.$i;
        $arrlnyc=M()->query("select {$data} from tb_lnyuncheng where id='{$yjNumber}'");
        $monthArr[$i]=$arrlnyc[0][$data];
    }
    $ln2019['monthArr']=$monthArr;
    return $ln2019;
}
//测终生运
function cezhongshengyun($dayungz,$dayunss){
    $data=session($dayungz[0].'arrlnbx');
    if(empty($data)){
        $arrlnbx=array();
        for($i=0;$i<20;$i++){array_push($arrlnbx,mt_rand(0,1));}
        $arrlnby=array();
        for($i=0;$i<20;$i++){array_push($arrlnby,mt_rand(1,8));}
        session($dayungz[0].'arrlnbx',$arrlnbx);
        session($dayungz[0].'arrlnby',$arrlnby);
    }
    $GLOBALS['arrlnbx']=session($dayungz[0].'arrlnbx');
    $GLOBALS['arrlnby']=session($dayungz[0].'arrlnby');

    $dayunss=array_merge($dayunss,$dayunss,$dayunss);
    $arrczsy=array();
    $n=1;
    for($i=0;$i<20;$i++){
        $arr=M()->query("select * from tb_cezhongshengyun where name='{$dayunss[$i]}'");
        $arrczsy[$n]=$arr[0];
        $n+=5;
    }
    $GLOBALS['arrczsy']=$arrczsy;
}

//婚缘走势
function hunyuanzs($zsizhu,$fsizhu,$zsizhuny,$fsizhuny,$zarryysz,$farryysz){
    $arrdtsz=M()->query("select experience from tb_wedlock where name='{$zsizhu[2]}'");
    $arrdtsf=M()->query("select experience from tb_wedlock where name='{$fsizhu[2]}'");
    $arrdts=array();array_push($arrdts,$arrdtsz[0]['experience'],$arrdtsf[0]['experience']);
    $Arr['arrdts']=$arrdts;
    $arraqgz=M()->query("select text from tb_hunyuanzs where name='男{$zsizhuny}'");
    $arraqgf=M()->query("select text from tb_hunyuanzs where name='女{$fsizhuny}'");
    $arraqg=array();array_push($arraqg,$arraqgz[0]['text'],$arraqgf[0]['text']);
    $Arr['arraqg']=$arraqg;
    $data=$zarryysz.$farryysz;
    $arrhyzs=M()->query("select * from tb_hunyuanzs where name='{$data}'");
    $Arr['arrhyzs']=$arrhyzs[0];
    $arrnum=S('arrnum'.$zsizhu[2]);
    if(empty($arrnum)){
        $arrnum=array();
        for($i=0;$i<3;$i++){
            array_push($arrnum,mt_rand(2,4));
            S('arrnum'.$zsizhu[2],$arrnum);
        }
    }
    $Arr['arrnum']=$arrnum;
    return $Arr;
}
//八字事业
function bzshiye($sizhuny,$shengxiao,$zymd,$sizhu,$wxsqs,$yearNum=null){
    $wuxing=mb_substr($sizhuny[2],2,1,'utf-8');
    $arrdata=M()->query("select * from tb_bzshiye where name='{$wuxing}'");
    $GLOBALS['bzshiye']=$arrdata[0];
    $y=mb_substr($zymd,0,4);$y+=$yearNum-1;
    $datax=($y%5)?$y%5:5;$datay=($datax+1<6)?$datax+1:1;
    $arrsy=M()->query("select cause{$datax},cause{$datay} from tb_fortune where name='{$shengxiao}'");
    $arrsyx=array();
    array_push($arrsyx,$arrsy[0]['cause'.$datax]);array_push($arrsyx,$arrsy[0]['cause'.$datay]);
    $GLOBALS['shiyeys']=$arrsyx;
    $data=mb_substr($sizhu[0],0,3);
    if(preg_match("/{$data}/",'甲戊庚')){$bzguirenp[0]='丑牛';$bzguirenp[1]='末羊';
    }else if(preg_match("/{$data}/",'乙己')){$bzguirenp[0]='子鼠';$bzguirenp[1]='申猴';
    }else if(preg_match("/{$data}/",'丙丁')){$bzguirenp[0]='亥猪';$bzguirenp[1]='酉鸡';
    }else if(preg_match("/{$data}/",'庚辛')){$bzguirenp[0]='寅虎';$bzguirenp[1]='午马';
    }else{$bzguirenp[0]='卯兔';$bzguirenp[1]='巳蛇';}
    $GLOBALS['bzguirenp']=$bzguirenp;
    $datax=mb_substr($wxsqs,0,1,'utf-8');$datay=mb_substr($wxsqs,4,1,'utf-8');
    $arrx=M()->query("select wang from tb_bzshiye where name='{$datax}'");
    $arry=M()->query("select ruo from tb_bzshiye where name='{$datay}'");
    $arrwr=array();array_push($arrwr,$arrx[0]['wang'],$arry[0]['ruo']);
    $GLOBALS['arrwr']=$arrwr;
}
//八字财运
function bzcaiyun($sizhu,$zymd){
    $ng=mb_substr($sizhu[0],0,1,'utf-8');
    $nz=mb_substr($sizhu[2],0,1,'utf-8');
    $arrcyd=M()->query("select * from tb_bzcaiyun where name='{$nz}'");
    $arrcyy=M()->query("select * from tb_bzcaiyun where name='{$ng}'");
    $GLOBALS['arrcyd']=$arrcyd[0];
    $GLOBALS['arrcyy']=$arrcyy[0];
    if(S('zpcai'.$sizhu[2])==''){$datazpc=mt_rand(60,80);S('zpcai'.$sizhu[2],$datazpc,2678400);}
    $GLOBALS['zpcai']=S('zpcai'.$sizhu[2]);
    if(S('wangyun'.$sizhu[2])==''){$datazpc=mt_rand(70,90);S('wangyun'.$sizhu[2],$datazpc,2678400);}
    $GLOBALS['wangyun']=S('wangyun'.$sizhu[2]);
    $y=mb_substr($zymd,0,4);//年
    $m=mb_substr($zymd,5,2);//月
    $d=mb_substr($zymd,8,2);//日
    $data=$y+$m+$d;$data%=64;if($data==0){$data=64;}
    $arr=M()->query("select * from tb_zy_lssgua where id={$data}");
    $GLOBALS['arrzygua']=$arr[0];
}
//婚姻测算
function hunyincesuan($ymd,$zhishen){
    $year=mb_substr($ymd,0,4);$xiehou=$year+21;$m=mb_substr($ymd,5,2);$d=mb_substr($ymd,8,2);$year=$year+$m+$d;
    $datath=($year%13)?$year%13:13;
    $arrhycs=M()->query("select * from tb_hunyincesuan where id={$datath}");
    $GLOBALS['arrhycs']=$arrhycs[0];
    $arrxiehou=array();
    for($i=0;$i<7;$i++){$xiehou+=1;if($i%2){$xiehou+=1;}array_push($arrxiehou,$xiehou);}
    $GLOBALS['arrxiehou']=$arrxiehou;
    $shujuZs=mb_substr($zhishen[2],0,2,'utf-8');
    $dzssshuju=M()->query("select * from tb_dzss_shuju where name='{$shujuZs}'");
    $GLOBALS['dzssshuju']=$dzssshuju[0];
    $pofraction=S('pofraction'.$zhishen[2]);
    if(empty($pofraction)){$pofraction=mt_rand(68,85);S('pofraction'.$zhishen[2],$pofraction,2560000);}
    $GLOBALS['pofraction']=$pofraction;
    $happiness=S('happiness'.$zhishen[2]);
    if(empty($happiness)){$happiness=mt_rand(75,95);S('happiness'.$zhishen[2],$happiness,2560000);}
    $GLOBALS['happiness']=$happiness;
    $zhuwang=S('zhuwang'.$zhishen[2]);
    if(empty($zhuwang)){$zhuwang=mt_rand(75,95);S('zhuwang'.$zhishen[2],$zhuwang,2560000);}
    $GLOBALS['zhuwang']=$zhuwang;
    $zinvfraction=S('zinvfraction'.$zhishen[2]);
    if(empty($zinvfraction)){$zinvfraction=mt_rand(75,95);S('zinvfraction'.$zhishen[2],$zinvfraction,2560000);}
    $GLOBALS['zinvfraction']=$zinvfraction;
}
//名人八字
function mingrenbazi($sizhu){//
    $mrbzArr=M()->query("select * from tb_data_mrbz where bazi like '%{$sizhu[0]}%' and bazi like '%{$sizhu[1]}%' and bazi like '%{$sizhu[2]}%' limit 1");
    if(empty($mrbzArr)){
        $mrbzArr=M()->query("select * from tb_data_mrbz where bazi like '{$sizhu[0]}%{$sizhu[1]}%{$sizhu[2]}%' limit 1");
        $data='与您八字其中6字相同：八字其中6字相同的人，城为六同生人。往往大范围的信息和人生大方面有很多相似之处，细节不会完全相同。';
    }else{
        $data='与您八字完全相同：八字相同的人往往人的性格喜好，人生经历模式、运势起伏、事业婚姻、财运身体健康等各个方面现象有很多相似之处。';
    }

    //$mrbzArr=M()->query("select * from tb_data_mrbz where bazi like '乙已%甲申%癸酉%' limit 1");
    $mrbzArr[0]['data']=$data;
    return $mrbzArr[0];
}
function mingrenbaziZW($sizhu,$mgWZ,$arrzx,$arrtf,$syzx,$snzx,$sxzx,$sngx,$qtx,$qyWZ){//
    $mrbzArr=M()->query("select * from tb_data_mrbz where bazi like '{$sizhu[0]}%{$sizhu[1]}%{$sizhu[2]}%' and id>130 limit 1");//八字前6字匹配

    $gwData=$arrzx[$mgWZ].$arrtf[$mgWZ].$syzx[$mgWZ].$snzx[$mgWZ].$sxzx[$mgWZ].$sngx[$mgWZ].$qtx[$mgWZ];
    if($arrzx[$mgWZ].$arrtf[$mgWZ]){
    }else{//命宫没有主星
        $gwData=$arrzx[$qyWZ].$arrtf[$qyWZ].$syzx[$qyWZ].$snzx[$qyWZ].$sxzx[$qyWZ].$sngx[$qyWZ].$qtx[$qyWZ];
    }
    if($arrzx[$mgWZ].$arrtf[$mgWZ]){
        $mrbzArrZW=M()->query("select id,ziwei from tb_data_mrbz where id>=128 and ziwei !='' and id>130");
        foreach($mrbzArrZW as $key=>$value){
            $ziweiArr=explode('、',$value['ziwei']);
            $judgeNum=1;
            foreach($ziweiArr as $k=>$v){
                if(!strstr($gwData,$v)){
                    $judgeNum=0;break;
                }
                if($arrzx[$mgWZ]){//主星检测
                    if(!strstr($value['ziwei'],$arrzx[$mgWZ])){$judgeNum=0;break;}
                }
                if($arrtf[$mgWZ]){//主星检测
                    if(!strstr($value['ziwei'],$arrtf[$mgWZ])){$judgeNum=0;break;}
                }
            }

            if($judgeNum==1){
                $ziweiId=$value['id'];
                break;
            }else{
                $ziweiId=0;
            }
        }
    }else {//命宫没有主星
        $mrbzArrZW=M()->query("select id,ziwei from tb_data_mrbz where ziwei like '%空宫%' and id>130");
        foreach($mrbzArrZW as $key=>$value){
            $ziweiArr=explode('、',$value['ziwei']);
            $judgeNum=1;
            foreach($ziweiArr as $k=>$v){
                if(strstr($gwData,mb_substr($v,-2,2,'utf-8'))){
                }else{
                    $judgeNum=0;break;
                }
                if($arrzx[$mgWZ]){//主星检测
                    if(!strstr($value['ziwei'],$arrzx[$mgWZ])){$judgeNum=0;break;}
                }
                if($arrtf[$mgWZ]){//主星检测
                    if(!strstr($value['ziwei'],$arrtf[$mgWZ])){$judgeNum=0;break;}
                }
            }
            if($judgeNum==1){
                $ziweiId=$value['id'];
                break;
            }else{
                $ziweiId=0;
            }
        }
    }

    //dump($ziweiId);
    if($ziweiId){
        $mrbzArrZW=M()->query("select * from tb_data_mrbz where id='{$ziweiId}'");
        $imgId=$mrbzArrZW[0]['id']-129;
        for($i=0;$i<=2;$i++){
            $imgData=array('jpg','jpeg','png');
            $dir=mb_substr(THINK_PATH,0,-9)."Public/images/Mrtm/{$imgId}.{$imgData[$i]}";
            if(file_exists($dir)){
                $imgName="{$imgId}.{$imgData[$i]}";
                break;
            }
        }
        $mrbzArrZW[0]['imgUrl']="https://{$_SERVER['HTTP_HOST']}/zhiming/Public/images/Mrtm/{$imgName}";
        $mrbzArrZW[0]['textStr']=mb_substr($mrbzArrZW[0]['text'],0,150,'utf-8').'...';
    }else{
        $mrbzArrZW=null;
    }
    if($mrbzArr[0]){
        $imgId=$mrbzArr[0]['id']-129;
        for($i=0;$i<=2;$i++){
            $imgData=array('jpg','jpeg','png');
            $dir=mb_substr(THINK_PATH,0,-9)."Public/images/Mrtm/{$imgId}.{$imgData[$i]}";
            if(file_exists($dir)){
                $imgName="{$imgId}.{$imgData[$i]}";
                break;
            }
        }
        $mrbzArr[0]['imgUrl']="https://{$_SERVER['HTTP_HOST']}/zhiming/Public/images/Mrtm/{$imgName}";
        $mrbzArr[0]['textStr']=mb_substr($mrbzArr[0]['text'],0,150,'utf-8').'...';
    }else{
        $mrbzArr=null;
    }

    $Arr=array(
        'zwData'=>$mrbzArrZW[0],
        'bzData'=>$mrbzArr[0],
    );

    return $Arr;
}
//紫薇斗数
function zsqk($srg,$arrzx,$arrtf,$jix,$xiongx,$typeJudge=null){//自身情况
    $mgwz=array_search('命宫',$srg);$qywz=array_search('迁移',$srg);
    $sywz=array_search('事业',$srg);$vbwz=array_search('财帛',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['zsqkwz']=$zsqkwz;
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}

    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }
    $zsqkzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    if($typeJudge){
        $Arr['zsqkzx']=$zsqkzx;
    }else{
        $GLOBALS['zsqkzx']=$zsqkzx;
    }

    //吉凶
    $jixing=$jix[$zsqkwz[0]].$jix[$zsqkwz[1]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐命宫,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    if($typeJudge){
        $Arr['zsqkjx']=$jixing;
    }else{
        $GLOBALS['zsqkjx']=$jixing;
    }


    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐命宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    //$dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    //if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    if($typeJudge){
        $Arr['zsqkxx']=$xiongxing;
    }else{
        $GLOBALS['zsqkxx']=$xiongxing;
    }

//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='命宫'");
    if($typeJudge){
        $Arr['mggongwei']=$mggongwei[0]['text'];
    }else{
        $GLOBALS['mggongwei']=$mggongwei[0]['text'];
    }

//宫位凶吉
    if(S('mgxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
        //cookie('mgxj'.$zsqkwz[0],$data,315360);
        S('mgxj'.$zsqkwz[0],$data,315360);
    }
    if($typeJudge){
        $Arr['mgxj']=S('mgxj'.$zsqkwz[0]);
    }else{
        $GLOBALS['mgxj']=S('mgxj'.$zsqkwz[0]);
    }

//自身状况
      $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='命宫'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    if($typeJudge){
        $Arr['mgarrzhux']=$arrzhux;
    }else{
        $GLOBALS['mgarrzhux']=$arrzhux;
    }


    $jxstrz=$jix[$zsqkwz[0]].$jix[$zsqkwz[1]].$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='命宫'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='命宫'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐命宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    if($typeJudge){
        $Arr['mgarrfuxz']=array_filter($arrfuxz);
        $Arr['mgarrfuxj']=array_filter($arrfuxj);
        return $Arr;
    }else{
        $GLOBALS['mgarrfuxz']=array_filter($arrfuxz);
        $GLOBALS['mgarrfuxj']=array_filter($arrfuxj);
    }
}
function hyqg($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//婚姻情感
    $mgwz=array_search('夫妻',$srg);$qywz=array_search('事业',$srg);
    $sywz=array_search('福德',$srg);$vbwz=array_search('迁移',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['hyqgwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}

    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }
    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['hyqgzx']=$hyqgzx;
    //吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐夫妻宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['hyqgjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐夫妻宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['hyqgxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='夫妻'");
    $GLOBALS['fqgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('fqxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('fqxj'.$zsqkwz[0],$data,315360);
        S('fqxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['fqxj']=S('fqxj'.$zsqkwz[0]);
    //婚姻状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='夫妻'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['fqarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$jix[$zsqkwz[1]].$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='夫妻'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='夫妻'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐夫妻宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['fqarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['fqarrfuxj']=array_filter($arrfuxj);

}
function cyzk($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//财运状况
    $mgwz=array_search('财帛',$srg);$qywz=array_search('福德',$srg);
    $sywz=array_search('命宫',$srg);$vbwz=array_search('事业',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['cyzkwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}

    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }
    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['cyzkzx']=$hyqgzx;
    //吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐财帛宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['cyzkjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐财帛宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['cyzkxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='财帛'");
    $GLOBALS['cbgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('cbxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('cbxj'.$zsqkwz[0],$data,315360);
        S('cbxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['cbxj']=S('cbxj'.$zsqkwz[0]);
    //财运状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='财帛'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['cbarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='财帛'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='财帛'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='财帛'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐财帛宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['cbarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['cbarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['cbarrfuxj']=array_filter($arrfuxj);
}
function syfz($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//事业发展
    $mgwz=array_search('事业',$srg);$qywz=array_search('夫妻',$srg);
    $sywz=array_search('财帛',$srg);$vbwz=array_search('命宫',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['syfzwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}

    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }
    //$dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    //if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['syfzzx']=$hyqgzx;
    //吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐事业宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['syfzjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐事业宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['syfzxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='事业'");
    $GLOBALS['sygongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('syxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('syxj'.$zsqkwz[0],$data,315360);
        S('syxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['syxj']=S('syxj'.$zsqkwz[0]);
    //事业状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='事业'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['syarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='事业'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='事业'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='事业'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐事业宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['syarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['syarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['syarrfuxj']=array_filter($arrfuxj);

}
function jkzt($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//健康状态
    $mgwz=array_search('疾厄',$srg);$qywz=array_search('父母',$srg);
    $sywz=array_search('兄弟',$srg);$vbwz=array_search('田宅',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['jkztwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['jkztzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐疾厄宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['jkztjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐疾厄宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['jkztxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='疾厄'");
    $GLOBALS['jegongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('jexj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('jexj'.$zsqkwz[0],$data,315360);
        S('jexj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['jexj']=S('jexj'.$zsqkwz[0]);
//疾厄状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='疾厄'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['jearrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='疾厄'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='疾厄'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='疾厄'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐疾厄宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['jearrfuxz']=array_filter($arrfuxz);
    $GLOBALS['jearrfuxd']=array_filter($arrfuxd);
    $GLOBALS['jearrfuxj']=array_filter($arrfuxj);
}
function jsdx($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//精神德行
    $mgwz=array_search('福德',$srg);$qywz=array_search('财帛',$srg);
    $sywz=array_search('迁移',$srg);$vbwz=array_search('夫妻',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['jsdxwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['jsdxzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐福德宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['jsdxjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐福德宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['jsdxxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='福德'");
    $GLOBALS['fdgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('fdxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('fdxj'.$zsqkwz[0],$data,315360);
        S('fdxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['fdxj']=S('fdxj'.$zsqkwz[0]);
//福德状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='福德'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['fdarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='福德'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='福德'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='福德'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐福德宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['fdarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['fdarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['fdarrfuxj']=array_filter($arrfuxj);
}
function znzk($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//子女状况
    $mgwz=array_search('子女',$srg);$qywz=array_search('田宅',$srg);
    $sywz=array_search('父母',$srg);$vbwz=array_search('部属',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['znzkwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['znzkzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐子女宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['znzkjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐子女宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['znzkxx']=$xiongxing;
//    dump($zsqkwz[0]);
//    exit;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='子女'");
    $GLOBALS['zngongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('znxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('znxj'.$zsqkwz[0],$data,315360);
        S('znxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['znxj']=S('znxj'.$zsqkwz[0]);
//子女状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='子女'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['znarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='子女'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='子女'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='子女'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐子女宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['znarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['znarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['znarrfuxj']=array_filter($arrfuxj);
}
function fmgx($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//父母关系
    $mgwz=array_search('父母',$srg);$qywz=array_search('疾厄',$srg);
    $sywz=array_search('部属',$srg);$vbwz=array_search('子女',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['fmgxwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['fmgxzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐父母宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['fmgxjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐父母宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['fmgxxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='父母'");
    $GLOBALS['fmgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('fmxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('fmxj'.$zsqkwz[0],$data,315360);
        S('fmxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['fmxj']=S('fmxj'.$zsqkwz[0]);
//父母状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='父母'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['fmarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='父母'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='父母'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='父母'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐父母宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['fmarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['fmarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['fmarrfuxj']=array_filter($arrfuxj);
}
function xdgx($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//兄弟关系
    $mgwz=array_search('兄弟',$srg);$qywz=array_search('部属',$srg);
    $sywz=array_search('田宅',$srg);$vbwz=array_search('疾厄',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['xdgxwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}

    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }
    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['xdgxzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐兄弟宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['xdgxjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐兄弟宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['xdgxxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='兄弟'");
    $GLOBALS['xdgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('xdxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('xdxj'.$zsqkwz[0],$data,315360);
        S('xdxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['xdxj']=S('xdxj'.$zsqkwz[0]);
//兄弟状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='兄弟'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['xdarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='兄弟'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='兄弟'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='兄弟'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐兄弟宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['xdarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['xdarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['xdarrfuxj']=array_filter($arrfuxj);
}
function tzjj($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//田宅家境
    $mgwz=array_search('田宅',$srg);$qywz=array_search('子女',$srg);
    $sywz=array_search('疾厄',$srg);$vbwz=array_search('兄弟',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['tzjjwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['tzjjzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐田宅宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['tzjjjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐田宅宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['tzjjxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='田宅'");
    $GLOBALS['tzgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('tzxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('tzxj'.$zsqkwz[0],$data,315360);
        S('tzxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['tzxj']=S('tzxj'.$zsqkwz[0]);
//田宅状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='田宅'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['tzarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='田宅'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='田宅'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='田宅'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐田宅宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['tzarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['tzarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['tzarrfuxj']=array_filter($arrfuxj);
}
function rjgx($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//人际关系
    $mgwz=array_search('部属',$srg);$qywz=array_search('兄弟',$srg);
    $sywz=array_search('子女',$srg);$vbwz=array_search('父母',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['rjgxwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['rjgxzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐部属宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['rjgxjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐部属宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['rjgxxx']=$xiongxing;
//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='部属'");
    $GLOBALS['bsgongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('bsxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('bsxj'.$zsqkwz[0],$data,315360);
        S('bsxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['bsxj']=S('bsxj'.$zsqkwz[0]);
//部属状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='部属'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['bsarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='部属'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='部属'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='部属'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐部属宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['bsarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['bsarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['bsarrfuxj']=array_filter($arrfuxj);
}
function qyfz($srg,$arrzx,$arrtf,$jix,$xiongx,$shua){//迁移发展
    $mgwz=array_search('迁移',$srg);$qywz=array_search('命宫',$srg);
    $sywz=array_search('夫妻',$srg);$vbwz=array_search('福德',$srg);
    $zsqkwz=array();
    array_push($zsqkwz,$mgwz,$qywz,$sywz,$vbwz);
    $GLOBALS['qyfzwz']=$zsqkwz;//位置
    $zsqkzx='';//拥有主星
    if(!empty($arrzx[$zsqkwz[0]])){$zsqkzx=mb_substr($arrzx[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
    if(!empty($arrtf[$zsqkwz[0]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[0]],0,2,'utf-8').',';}
    //if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    if(empty($zsqkzx)){
        if(!empty($arrzx[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrzx[$zsqkwz[1]],0,2,'utf-8').',';}
        if(!empty($arrtf[$zsqkwz[1]])){$zsqkzx=$zsqkzx.mb_substr($arrtf[$zsqkwz[1]],0,2,'utf-8').',';}
    }

    $hyqgzx=substr($zsqkzx,0,strlen($zsqkzx)-1);
    $GLOBALS['qyfzzx']=$hyqgzx;
//吉凶
    $jixing=$jix[$zsqkwz[0]];
    if(!empty($jixing)){$jixing=substr($jixing,0,strlen($jixing)-1).'坐迁移宫,';}
    $jixingy=$jix[$zsqkwz[1]];
    if(!empty($jixingy)){$jixing=$jixing.substr($jixingy,0,strlen($jixingy)-1).'对照,';}
    $jixingx=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]];
    if(!empty($jixingx)){$jixing=$jixing.substr($jixingx,0,strlen($jixingx)-1).'加会,';}
    $datalu=stristr($hyqgzx,$shua[0]['hlu']);//化禄
    if(!empty($datalu)){$jixing=$jixing.$shua[0]['hlu'].'化禄,';}
    $dataquan=stristr($hyqgzx,$shua[0]['hquan']);//化权
    if(!empty($dataquan)){$jixing=$jixing.$shua[0]['hquan'].'化权,';}
    $datake=stristr($hyqgzx,$shua[0]['hke']);//化科
    if(!empty($datake)){$jixing=$jixing.$shua[0]['hke'].'化科,';}
    $jixing=substr($jixing,0,strlen($jixing)-1);
    $GLOBALS['qyfzjx']=$jixing;

    $xiongxing=$xiongx[$zsqkwz[0]].$xiongx[$zsqkwz[1]];
    if(!empty($xiongxing)){$xiongxing=substr($xiongxing,0,strlen($xiongxing)-1).'坐迁移宫,';}
    $xiongxingx=$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    if(!empty($xiongxingx)){$xiongxing=$xiongxing.substr($xiongxingx,0,strlen($xiongxingx)-1).'加会,';}
    $dataji=stristr($hyqgzx,$shua[0]['hji']);//化忌
    if(!empty($dataji)){$xiongxing=$xiongxing.$shua[0]['hji'].'化忌,';}
    $xiongxing=substr($xiongxing,0,strlen($xiongxing)-1);
    $GLOBALS['qyfzxx']=$xiongxing;

//宫位
    $dizhix=array('寅','卯','辰','巳','午','未','申','酉','戌','亥','子','丑');
    $mggongwei=M()->query("select * from tb_zwds_dizhi where dizhi='{$dizhix[$zsqkwz[0]]}' and palace='迁移'");
    $GLOBALS['qygongwei']=$mggongwei[0]['text'];
//宫位凶吉
    if(S('qyxj'.$zsqkwz[0])==''){$data=mt_rand(60,100).'.'.mt_rand(10,99);
//        cookie('qyxj'.$zsqkwz[0],$data,315360);
        S('qyxj'.$zsqkwz[0],$data,315360);
    }
    $GLOBALS['qyxj']=S('qyxj'.$zsqkwz[0]);
//迁移状况
    $arrzx=explode(',',$zsqkzx);
    $arrzx=array_filter($arrzx);
    $arrzhux=array();
    foreach($arrzx as $key=>$value){
        $arr=M()->query("select * from tb_zwds_zhuxing where star='{$value}' and palace='迁移'");
        $arr[0]=array_filter($arr[0]);
        $arrzhux=array_merge($arrzhux,$arr);
    }
    $GLOBALS['qyarrzhux']=$arrzhux;

    $jxstrz=$jix[$zsqkwz[0]].$xiongx[$zsqkwz[0]];
    $jxstrd=$jix[$zsqkwz[1]].$xiongx[$zsqkwz[1]];
    $jxstrh=$jix[$zsqkwz[2]].$jix[$zsqkwz[3]].$xiongx[$zsqkwz[2]].$xiongx[$zsqkwz[3]];
    $arrfxz=explode(',',substr($jxstrz,0,strlen($jxstrz)-1));$arrfuxz=array();
    $arrfxd=explode(',',substr($jxstrd,0,strlen($jxstrd)-1));$arrfuxd=array();
    $arrfxj=explode(',',substr($jxstrh,0,strlen($jxstrh)-1));$arrfuxj=array();
    foreach($arrfxz as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='迁移'");
        $arrfuxz=array_merge($arrfuxz,$arr);}
    foreach($arrfxd as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='迁移'");
        $arrfuxd=array_merge($arrfuxd,$arr);}
    foreach($arrfxj as $key=>$value){
        $arr=M()->query("select * from tb_zwds_fuxing where star='{$value}' and palace='迁移'");
        $arrfuxj=array_merge($arrfuxj,$arr);}
    for($i=0;$i<count($arrfuxz);$i++){
        if($arrfuxz[$i]['text']==$arrfuxz[$i+1]['text']){
            $arrfuxz[$i]['star']=$arrfuxz[$i]['star'].'坐迁移宫,'.$arrfuxz[$i+1]['star'];
            $arrfuxz[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxd);$i++){
        if($arrfuxd[$i]['text']==$arrfuxd[$i+1]['text']){
            $arrfuxd[$i]['star']=$arrfuxd[$i]['star'].'对照,'.$arrfuxd[$i+1]['star'];
            $arrfuxd[$i+1]='';$i++;}}
    for($i=0;$i<count($arrfuxj);$i++){
        if($arrfuxj[$i]['text']==$arrfuxj[$i+1]['text']){
            $arrfuxj[$i]['star']=$arrfuxj[$i]['star'].'加会,'.$arrfuxj[$i+1]['star'];
            $arrfuxj[$i+1]='';$i++;}}
    $GLOBALS['qyarrfuxz']=array_filter($arrfuxz);
    $GLOBALS['qyarrfuxd']=array_filter($arrfuxd);
    $GLOBALS['qyarrfuxj']=array_filter($arrfuxj);
}
function hualu($shua){//化禄
    $arr=M()->query("select * from tb_sihua_lu where star='{$shua[0]['hlu']}'");
    $GLOBALS['hualu']=$arr[0];
}


function xingmingZft($xing,$ming){//转笔画
    $channel=cookie('channel');
    $xingLeng=strlen($xing)/3;

    $Xbihua=array();
    $Xbihua=S('Xbihua'.$xing);
    if(empty($Xbihua)){
        for($i=0;$i<$xingLeng;$i++){
            $word=mb_substr($xing,$i,1,'utf-8');
            $url = "https://bihua.911cha.com/?q={$word}";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);//设置请求地址
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//不需要证书验证
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//不需要主机验证
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//不直接输出到页面
            $json = curl_exec($ch);

            preg_match("/class=\"bihua\"[\s\S]*画<\/span>/",$json,$matches);
            preg_match("/>[\s\S]*画/",$matches[0],$bihua);
            $Xbihua[$i]=intval(mb_substr($bihua[0],1,2));
            cookie('Xbihua',$Xbihua);
        }
        S('Xbihua'.$xing,$Xbihua,186400);
    }

    $mingLeng=strlen($ming)/3;
    $Mbihua=array();
    $Mbihua=S('Mbihua'.$ming);
    if(empty($Mbihua)){
        for($i=0;$i<$mingLeng;$i++){
            $word=mb_substr($ming,$i,1,'utf-8');
            $url = "https://bihua.911cha.com/?q={$word}";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);//设置请求地址
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//不需要证书验证
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//不需要主机验证
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//不直接输出到页面
            $json = curl_exec($ch);

            preg_match("/class=\"bihua\"[\s\S]*画<\/span>/",$json,$matches);
            preg_match("/>[\s\S]*画/",$matches[0],$bihua);
            $Mbihua[$i]=intval(mb_substr($bihua[0],1,2));
            if($word=='茁'){
                $Mbihua[$i]=11;
            }
            cookie('Mbihua',$Mbihua);
        }
        S('Mbihua'.$ming,$Mbihua,186400);
    }


    //$GLOBALS['bihua']=array_merge($Xbihua,$Mbihua);
    $Arr=array_merge($Xbihua,$Mbihua);
    return $Arr;
}

//姓名测算
function xmcs($ymd,$hour){
    $Xbihua=cookie('Xbihua');
    $Mbihua=cookie('Mbihua');
    $strMbihua=count($Mbihua);
    $trdwz=array();
    //天格
    if($Xbihua[1]==''){$trdwz['tian']['number']=$Xbihua[0]+1;
    }else{
        foreach($Xbihua as $value){$trdwz['tian']['number']+=$value;}
    }
    //人格
    $renNum=0;
    foreach($Xbihua as $value){$renNum+=$value;}
    $renNum+=$Mbihua[0];
    $trdwz['ren']['number']=$renNum;
    //地格
    if($Mbihua[1]==''){$trdwz['di']['number']=$Mbihua[0]+1;
    }else{
        foreach($Mbihua as $value){$trdwz['di']['number']+=$value;}
    }
    //外格
    if(!$Xbihua[1]&&!$Mbihua[1]){$trdwz['wai']['number']=2;
    }else{$trdwz['wai']['number']=$Mbihua[$strMbihua-1]+1;}
    //总格
    $xzNum=0;
    $mzNum=0;
    foreach($Xbihua as $value){$xzNum+=$value;}
    foreach($Mbihua as $value){$mzNum+=$value;}
    $trdwz['zong']['number']=$xzNum+$mzNum;

    $hudongXJ=array();
    foreach($trdwz as $key=>$value){
        $number=$value['number'];
        if($number%10==1 || $number%10==2)$trdwz[$key]['wx']='木';
        if($number%10==3 || $number%10==4)$trdwz[$key]['wx']='火';
        if($number%10==5 || $number%10==6)$trdwz[$key]['wx']='土';
        if($number%10==7 || $number%10==8)$trdwz[$key]['wx']='金';
        if($number%10==9 || $number%10==0)$trdwz[$key]['wx']='水';
        $xjArr=M()->query("select xj from tb_namecs_numberxj where id={$number}");
        $trdwz[$key]['xj']=$xjArr[0]['xj'];
        array_push($hudongXJ,$xjArr[0]['xj']);
    }
    $GLOBALS['trdwz']=$trdwz;

    //三才配置
    $cswxName=$trdwz['tian']['wx'].$trdwz['ren']['wx'].$trdwz['di']['wx'];
    $csArr=M()->query("select * from tb_namecs_sancai where name='{$cswxName}'");
    $GLOBALS['sancai']=$csArr[0];
    array_push($hudongXJ,$csArr[0]['xj']);

    //互动关系
    $hdjyArr=array('95'=>'备受父母、长辈的关爱与照顾，多属于“天之骄子”型，长辈的疼爱与提拔较多，但千万注意，应知福惜福，不要骄纵与得意忘形。',
        '90'=>'长辈、父母与自己互为贵人，父母属理性型，并非强烈要求的那一型，自己和长辈、上司能和睦相处，但却未必能心灵相通，形态上是互相尊重而不是亲昵的形态，至于是否有助力，得看自己的能力表现。',
        '80'=>'对父母照顾有加，是光宗耀祖或孝顺父母型，会尊敬长辈，对父母、长辈服从性强，也会维护家族权益，关心亲人状况。',
        '60'=>'父母、长辈属于比较老实古板型，或不懂子女心态，或照顾不够周到，或比较唠叨等。本身长辈缘也欠佳，在工作或事业方面比较难得到长辈或上司的赏识与提拔。');
    $hdcgyArr=array('95'=>'可以得到能力强的配偶来帮忙，亲戚朋友也都有助力，同时也受部属爱戴，就是那种被说成：“您真是好命”的人，捅了篓子，好像也有人代过，无形中就有一份幸运相伴，是一个不管事，却都不太会出事的主管。不过，别高兴太早，当大运不佳时，就没这么轻松了，反过来，可能疲于奔命来摆平莫名其妙的意外，亲朋好友的助力也会减低。',
        '90'=>'与配偶或部属的关系在意识形态上就像在一定的轨道上行进，一切都很正常，彼此互相尊重，也有一定的向心力，但有时却又好像平平淡淡的，缺少一种激情的演出，没有灿烂的火花，也没有什么大事发生，反正平安就是福嘛！算不错了。',
        '80'=>'天生耳根子软，容易受骗上当，有受人拖累而遭遇损失的倾向，一生必须为家庭付出更多的辛劳，却不见得能改善什么，同时也不容易得到亲友的帮助，给人的恩惠彷佛是应该的。同时又学不乖，好像注定是苦命的好人！为了整个家庭的运转，包含精神体力之支配，付出相当的大。 ',
        '60'=> '看似充满大男子主义或大女子主义的味道。子女的体质较弱，病痛也较多，常在子女的照顾上烦心。在表现上又好像很照顾子女，唯令人感受不到照顾子女的心，不过并非代表不关心子女。行事风格较具侵略性，对别人要求较高，对部属而言，属于一丝不苟、严厉型的主管，家庭方面也是权威十足，对于各种求财的欲望强，筹划多，喜居上位驱使别人，主观强，固执己见，喜以命令口吻做事。');
    $hdsjy=array('95'=>'本身外在人缘不错，兄弟贵人助力也多，个性是属乐观进取且是交游广阔型，朋友多，善交际，且都有实质上的帮助，当不如意时自然有朋友会伸出援手，尤其是财务方面，因朋友财力方面的帮助，不但转危为安，还有更上层楼的意思。而在事业工作上有发展的机会，一生贵人虽多，唯忌依赖心过重，一心盼望别人帮助。如具有慈善之心，能脚踏实地的做，则一生成功在望。',
        '90'=>'基本上是属平凡型，为人不会惹人注目，也不会被人吃定，跟朋友相处会有一定的默契，朋友有事会主动帮忙，自己有事朋友也会帮忙，如果数理皆吉，则贵人运强，处处逢凶化吉，得到很多的助力。',
        '80'=>'本身一直想往外扩充发展，易受外界诱惑，充满美丽的幻想，能于社会上有所表现，本身有艺术才华，人缘交际关系不错，但好像表面上好看，其实内心空虚、事情特多，有反复不定之象。一生中可以为朋友两肋插刀，朋友的事就是自己的事，待人宽宏大量，不计前嫌，为事业伙伴或朋友吃亏受累是小事一桩，常会为朋友解决事情而惹了一身腥也义无反顾，所以人际关系良好，能得朋友信任。',
        '60'=>'外格可以看部属、朋友、事业，因相克所以运不佳，常生异心，真心无悔付出，却得不到善意的响应，往往自己好不容易有个好事业伙伴，却被人轻易的挖走，用心培植出来，认为可堪大用的人才，却带枪投靠他人，而且亲朋好友之间是非也多。自己有事没事就被流弹所伤，受了委曲又无处诉，精神上无谓的困扰层出不穷。命带固执，侍傲不服输，在内心充满反动意识，想独当一面及领导或当主管或带头，是为“强人型”，做事有冲劲较敢表现，对于财物之追求欲望强。',
        '45'=>'容易被欺负，为人已经是低声下气了，很奇怪就是交不到好朋友，好像谁都是他的债主，经常被朋友拖累。好事没份，倒霉麻烦事一堆，有时破财还不一定消得了灾，更奇怪的是发生过的事已受到教训，还毫无自知之明，又经常往火坑里跳。不应碰的却偏喜欢去碰，常常吃力不讨好，又得不到人家的感恩图报。');
    $hdjty=array('95'=>'在外：人缘交际、处事方面，可达到理想地步，在内：身为家中一份子会共创美好的末来，付出劳力，本身在金钱上使用不富裕，因为要建立美好家园的关系。',
        '90'=> '家庭成员在内：能和睦相处，在外：人缘交际、处事方面均可达到和睦共处的地步，会与朋友共创美好的未来，朋友也会认同我们的想法，要注意本身在金钱上使用不很富裕，要节俭一点，日子才会好过。',
        '80'=>'从子女方面来看还算听话，在家里也应该有很好的享受，但却禁不起外界的诱惑，而受其影响忙碌，个性喜往外及接受大自然，认为外面灯红酒绿的世界较为有趣味，有虚华而不实在的感觉。喜欢往外轻松一下，对吗？',
        '60'=>'可能会有第三者介入家庭内而引起家庭革命，一生中易破财，在情感方面易有出轨的现象，不如意之事常带回家中，造成紧张而使家运不顺，精神不安及身体疾病等等，切记多说好话，多做好事就能消灾。');
    $hdgrtx=array('95'=>'此种格局一生中贵人很多，是一个幸运儿，也比较适合创业做生意，而且经常会有意外收获，记得当不如意时，就找朋友商量，就会有意想不到的好办法出现。',
        '90'=>'为人是一个说到做到且表里如一的人，为人坦率，不会做作，也不喜奉承，与人交往时，或许无法得到立即的认同，但好酒是愈陈愈香，最后一定会得到认同，为人信用很好，每每言出必行，不会打折扣，所以可以取得人家的信任，适合自行创业，虽然不一定是一炮而红的类型，但也能顺顺利利地，一步一步迈向成功之路。',
        '80'=>'此种格局会因本身节俭而得财，一生贵人多扶助，一生多辛劳，奋斗不懈，能发挥潜在的艺术才华，终究能实现愿望并获得成功，是属于脚踏实地型，做任何事都有预备、规划，然后按部就班，一分实力做一分事，可稳定成长，内心的思想也是踏踏实实的，不会想要一步登天，与子息较有亲近的机会，晚运佳，更能扶助事业而扬名。',
        '60'=>'对财物欲望的需求旺盛，做事也比较想求表现，有时常超出能力范围，金钱花费很厉害，财运起伏大，一生中破耗不少，另外在感情方面缘份较淡薄。属个性刚硬，很难对人或事服气的人，每每犯错又总是一副很有理的样子，而且还不听劝告，凡事自以为是，错了也要错到底，如果在工作上，一遇到这种主管就很累人了，不照做不行，照做出了毛病，他又未必负责，真是很烦人。',
        '45'=>'此种格局一生总是埋头苦干，但往往天不如人愿，再怎么做都不如意，是属勤苦耐劳型，因人格被克，所以就会感觉压力很重，所以一生运势难免大打折扣，如果要成功，必须比别人付出更大的恒心与毅力才行。');
    $hdjtgx=array('95'=>'下属及配偶助力，代表能得到一位好配偶，尤其在事业方面的帮助很大，而且配偶是属于辅佐型的，不会和你争着掌权发令，而且又能分摊掉大部分的责任，下属及配偶虽未必聪明过人，但相当干练，也任劳任怨。若是夫妻共同创业，不但有相辅相成之功，双方都善于营造愉快的气氛，可说人气、财气皆旺。',
        '90'=>'是属于欢乐型，家庭关系、子女关系，和乐融融，全家向心力很强，彼此互相关心，不过有时会有牵绊感，一般在意见沟通上是采取民主方式，没有权威的压迫感，夫妻间各自独立，各有自己的领域，感情世界也是较理性的，子女身体健康，聪明活泼，功课方面也不用太操心，一家人相处亦亲亦友，是让人称羡的现代化家庭，这种生活模式很不错。',
        '80'=>'夫妻间谁主内或主外都各自独立，各有自己的领域，感情世界也是较理性的，子女身体健康，聪明活泼，功课方面也不用太操心，一家人相处和乐，美满现代化的家庭生活典范。家庭关系有点黏又不会太黏，和乐融融，向心力很强，彼此关心，意见沟通上采取民主式双向沟通，没有强势的权威感。',
        '60'=>'是属于麻烦型，家庭里会纷纷扰扰的，比较不得安宁，配偶对事情的感觉比较神经质，而自己又好不到哪里去，有时，经常会为一点小事闹得不可开交，事后又后悔，常骂自己是神经病，常常一言不合又吵起来了，总是没完没了的。探究原因是个性的成熟度不够，情绪的控制也不好。子女运亦不佳，身体和功课方面不太理想，若再加上经济因素，就是标准的“贫贱夫妻百事哀”的结局。',
        '45'=>'整个家庭气氛不是很好，有沟通不良之倾向，主要问题出在配偶及小孩对生活上的要求，在配合度上，无法取得适当的协调，以至于沉积种种的不满，而表达的方式又非心平气和的理性沟通，反而是牢骚、埋怨的方式，徒增困扰，想不出方法可以解决。之所以会有这种情形出现，起因是一开始就不懂用疏导来化解，日久养成习惯，变成看到什么事不念一念就不痛快，很难改变这种现象，因为这已是习惯较难改变，除非痛下决心，或可慢慢改善。');
    $hdgxArr[0]=$hdjyArr;$hdgxArr[1]=$hdcgyArr;
    $hdgxArr[2]=$hdsjy;$hdgxArr[3]=$hdjty;
    $hdgxArr[4]=$hdgrtx;$hdgxArr[5]=$hdjtgx;
    $hudongGX=array();
    foreach( $hudongXJ as $key=>$value){
        if($hudongXJ[$key]=='大吉' || $hudongXJ[$key]=='吉'){
            if($hudongXJ[$key+1]=='吉'){$number=95;}else{$number=90;}
            if($hudongXJ[$key+1]==''){
                if($hudongXJ[$key-1]=='大吉'){$number=95;}else{$number=90;}
            }
            $hudongGX[$key]['text']=$hdgxArr[$key][$number];
            $hudongGX[$key]['number']=$number;
        }
        if($hudongXJ[$key]=='半吉'){
            $number=80;
            $hudongGX[$key]['text']=$hdgxArr[$key][$number];
            $hudongGX[$key]['number']=$number;
        }
        if($hudongXJ[$key]=='凶' || $hudongXJ[$key]=='半凶'){
            if($hudongXJ[$key+1]=='凶'){$number=45;}else{$number=60;}
            if($hudongXJ[$key+1]==''){
                if($hudongXJ[$key-1]=='凶'){$number=45;}else{$number=60;}
            }
            if($hdgxArr[$key][$number]==''){$number=60;}
            $hudongGX[$key]['text']=$hdgxArr[$key][$number];
            $hudongGX[$key]['number']=$number;
        }
    }
    $GLOBALS['hudongGX']=$hudongGX;

    //评分
    $fraction=array();
    foreach($hudongXJ as $key=>$value){
       if($hudongXJ[$key]=='大吉'){$fraction[0]+=20;}
        if($hudongXJ[$key]=='吉'){$fraction[0]+=18;}
        if($hudongXJ[$key]=='半吉'){$fraction[0]+=16;}
        if($hudongXJ[$key]=='凶'){$fraction[0]+=10;}
    }
    if($fraction[0]>120)$fraction[0]-=21;
    if($fraction[0]<110&&$fraction[0]>100)$fraction[0]-=11;

    $year=mb_substr($ymd,0,4);
    $m=mb_substr($ymd,5,2);
    $d=mb_substr($ymd,8,2);
    $bzpf=$year+$m+$d+$hour;
    for($i=60;$i<99;$i++){
        $data=$bzpf%$i;
        if($data>60){$fraction[1]=$data;break;}else{$fraction[1]=80;}
    }
    $GLOBALS['fraction']=$fraction;

    //五格数理解析
    $shuliJX=array();
    foreach($trdwz as $key=>$value){
        if($value['number']>81){$number=$value['number']-81;
        }else{$number=$value['number'];}
        $shuliArr=M()->query("select * from tb_namecs_numberxj where id='{$number}'");
        $shuliJX[$key]=$shuliArr[0];
    }
    $GLOBALS['shuliJX']=$shuliJX;

    //幸运物
    $luckHuaNum=$year+$m+$d+$hour;
    $luckHuaNum=$luckHuaNum%12>0?$luckHuaNum%12:1;
    $luckHuaArr=M()->query("select * from tb_constellation where id='{$luckHuaNum}'");
    $GLOBALS['luckHua']=$luckHuaArr[0];
    $luckshitouNum=$year+$m+$d;
    $luckshitouNum=$luckshitouNum%12>0?$luckshitouNum%12:1;
    $luckshitouArr=M()->query("select * from tb_constellation where id='{$luckshitouNum}'");
    $GLOBALS['luckshitou']=$luckshitouArr[0];

}

//周易起卦
function zhouyiqigua($guaxiang,$sizhu){
    $arryouhun=array('火地晋','雷山小过','天水讼','泽风大过','山雷颐','地火明夷','风山渐','水天需');//游魂
    $arrguihun=array('火天大有','雷泽归妹','天火同人','泽雷随','山风蛊','地水师','风山渐','水地比');//归魂
    $arrliuchong=array('乾为天','兑为泽','离为火','震为雷','巽为风','坎为水','艮为山','坤为地','天雷无妄','雷天大壮');//六冲
    $arrliuhe=array('天地否','水泽节','山火贲','雷地豫','火山旅','地雷复','地天泰','泽水困');//六合
    $bengua=$guaxiang;$biangua=$guaxiang;
    for($i=1;$i<=6;$i++){
        if($guaxiang[$i]==3||$guaxiang[$i]==1){$bengua[$i]=1;}else{$bengua[$i]=2;}
    }
    for($i=1;$i<=6;$i++){
        if($guaxiang[$i]==3){$biangua[$i]=2;}else if($guaxiang[$i]==4){$biangua[$i]=1;}
    }
    $yao1=$bengua[1];$yao2=$bengua[2];$yao3=$bengua[3];$yao4=$bengua[4];$yao5=$bengua[5];$yao6=$bengua[6];
    if($yao4==1&&$yao5==1&&$yao6==1){$sgua='qiantian';
    }else if($yao4==1&&$yao5==1&&$yao6==2){$sgua='duize';
    }else if($yao4==1&&$yao5==2&&$yao6==1){$sgua='lihuo';
    }else if($yao4==1&&$yao5==2&&$yao6==2){$sgua='zhenlei';
    }else if($yao4==2&&$yao5==1&&$yao6==1){$sgua='xunfeng';
    }else if($yao4==2&&$yao5==1&&$yao6==2){$sgua='kanshui';
    }else if($yao4==2&&$yao5==2&&$yao6==1){$sgua='genshan';
    }else if($yao4==2&&$yao5==2&&$yao6==2){$sgua='kundi';}
    if($yao1==1&&$yao2==1&&$yao3==1){$xgua='乾天';
    }else if($yao1==1&&$yao2==1&&$yao3==2){$xgua='兑泽';
    }else if($yao1==1&&$yao2==2&&$yao3==1){$xgua='离火';
    }else if($yao1==1&&$yao2==2&&$yao3==2){$xgua='震雷';
    }else if($yao1==2&&$yao2==1&&$yao3==1){$xgua='巽风';
    }else if($yao1==2&&$yao2==1&&$yao3==2){$xgua='坎水';
    }else if($yao1==2&&$yao2==2&&$yao3==1){$xgua='艮山';
    }else if($yao1==2&&$yao2==2&&$yao3==2){$xgua='坤地';}
    $benguadata=M()->query("select {$sgua} from tb_shangxiaguacx where name='{$xgua}'");
    $arrbengua=M()->query("select * from tb_zy_lssgua where name='{$benguadata[0][$sgua]}'");
    if(array_search($arrbengua[0]['name'],$arryouhun)){
        $arrbengua[0]['name']=$arrbengua[0]['name'].'(游魂)';}
    if(array_search($arrbengua[0]['name'],$arrguihun)){
        $arrbengua[0]['name']=$arrbengua[0]['name'].'(归魂)';}
    if(array_search($arrbengua[0]['name'],$arrliuchong)){
        $arrbengua[0]['name']=$arrbengua[0]['name'].'(六冲)';}
    if(array_search($arrbengua[0]['name'],$arrliuhe)){
        $arrbengua[0]['name']=$arrbengua[0]['name'].'(六合)';}
    $GLOBALS['arrbengua']=$arrbengua[0];

    //宫位六亲  金木水火土    $gonweilq=array('','','','','');
    $bengong=mb_substr($arrbengua[0]['gua'],0,1,'utf-8');
    if($bengong=='乾'){$gonweilq=array('兄弟','妻财','子孙','官鬼','父母');
    }else if($bengong=='震'){$gonweilq=array('官鬼','兄弟','父母','子孙','妻财');
    }else if($bengong=='坎'){$gonweilq=array('父母','子孙','兄弟','妻财','官鬼');
    }else if($bengong=='艮'){$gonweilq=array('子孙','官鬼','妻财','父母','兄弟');
    }else if($bengong=='坤'){$gonweilq=array('子孙','官鬼','妻财','父母','兄弟');
    }else if($bengong=='巽'){$gonweilq=array('官鬼','兄弟','父母','子孙','妻财');
    }else if($bengong=='离'){$gonweilq=array('妻财','父母','官鬼','兄弟','子孙');
    }else if($bengong=='兑'){$gonweilq=array('兄弟','妻财','子孙','官鬼','父母');
    }

    if($bengua!=$biangua){//变卦是否执行
        $yao1=$biangua[1];$yao2=$biangua[2];$yao3=$biangua[3];$yao4=$biangua[4];$yao5=$biangua[5];$yao6=$biangua[6];
        $bguaxiang=array('',$yao1,$yao2,$yao3,$yao4,$yao5,$yao6);
        $GLOBALS['bguaxiang']=$bguaxiang;
        if($yao4==1&&$yao5==1&&$yao6==1){$sgua='qiantian';
        }else if($yao4==1&&$yao5==1&&$yao6==2){$sgua='duize';
        }else if($yao4==1&&$yao5==2&&$yao6==1){$sgua='lihuo';
        }else if($yao4==1&&$yao5==2&&$yao6==2){$sgua='zhenlei';
        }else if($yao4==2&&$yao5==1&&$yao6==1){$sgua='xunfeng';
        }else if($yao4==2&&$yao5==1&&$yao6==2){$sgua='kanshui';
        }else if($yao4==2&&$yao5==2&&$yao6==1){$sgua='genshan';
        }else if($yao4==2&&$yao5==2&&$yao6==2){$sgua='kundi';}
        if($yao1==1&&$yao2==1&&$yao3==1){$xgua='乾天';
        }else if($yao1==1&&$yao2==1&&$yao3==2){$xgua='兑泽';
        }else if($yao1==1&&$yao2==2&&$yao3==1){$xgua='离火';
        }else if($yao1==1&&$yao2==2&&$yao3==2){$xgua='震雷';
        }else if($yao1==2&&$yao2==1&&$yao3==1){$xgua='巽风';
        }else if($yao1==2&&$yao2==1&&$yao3==2){$xgua='坎水';
        }else if($yao1==2&&$yao2==2&&$yao3==1){$xgua='艮山';
        }else if($yao1==2&&$yao2==2&&$yao3==2){$xgua='坤地';}
        $bianguadata=M()->query("select {$sgua} from tb_shangxiaguacx where name='{$xgua}'");
        $arrbiangua=M()->query("select * from tb_zy_lssgua where name='{$bianguadata[0][$sgua]}'");
        if(array_search($arrbiangua[0]['name'],$arryouhun)){
            $arrbiangua[0]['name']=$arrbiangua[0]['name'].'(游魂)';}
        if(array_search($arrbiangua[0]['name'],$arrguihun)){
            $arrbiangua[0]['name']=$arrbiangua[0]['name'].'(归魂)';}
        if(array_search($arrbiangua[0]['name'],$arrliuchong)){
            $arrbiangua[0]['name']=$arrbiangua[0]['name'].'(六冲)';}
        if(array_search($arrbiangua[0]['name'],$arrliuhe)){
            $arrbiangua[0]['name']=$arrbiangua[0]['name'].'(六合)';}
        for($i=1;$i<=6;$i++){
            $datalq=mb_substr($arrbiangua[0]['sxgua'.$i],0,2,'utf-8');
            $datawx=mb_substr($arrbiangua[0]['sxgua'.$i],4,1,'utf-8');
            if($datawx=='金'){$data=str_replace($datalq,$gonweilq[0],$arrbiangua[0]['sxgua'.$i]);
            }else if($datawx=='木'){$data=str_replace($datalq,$gonweilq[1],$arrbiangua[0]['sxgua'.$i]);
            }else if($datawx=='水'){$data=str_replace($datalq,$gonweilq[2],$arrbiangua[0]['sxgua'.$i]);
            }else if($datawx=='火'){$data=str_replace($datalq,$gonweilq[3],$arrbiangua[0]['sxgua'.$i]);
            }else{$data=str_replace($datalq,$gonweilq[4],$arrbiangua[0]['sxgua'.$i]);
            }
            $arrbiangua[0]['sxgua'.$i]=$data;
        }
        $GLOBALS['arrbiangua']=$arrbiangua[0];
    }else{
        $GLOBALS['arrbiangua']='';
        $GLOBALS['bguaxiang']='';
    }
    $rizhux=mb_substr($sizhu[2],0,1,'utf-8');
    if($rizhux=='甲'||$rizhux=='乙'){$arrliushou=array('青龙','朱雀','勾陈','腾蛇','白虎','玄武');
    }else if($rizhux=='丙'||$rizhux=='丁'){$arrliushou=array('朱雀','勾陈','腾蛇','白虎','玄武','青龙');
    }else if($rizhux=='戊'){$arrliushou=array('勾陈','腾蛇','白虎','玄武','青龙','朱雀');
    }else if($rizhux=='己'){$arrliushou=array('腾蛇','白虎','玄武','青龙','朱雀','勾陈');
    }else if($rizhux=='庚'||$rizhux=='辛'){$arrliushou=array('白虎','玄武','青龙','朱雀','勾陈','腾蛇');
    }else{$arrliushou=array('玄武','青龙','朱雀','勾陈','腾蛇','白虎');}
    $GLOBALS['arrliushou']=$arrliushou;

    //神煞
    $rig=mb_substr($sizhu[2],0,1,'utf-8');
    $riz=mb_substr($sizhu[2],1,1,'utf-8');$shensha=array();
    if($rig=='甲'){$shensha[0]='丑未';$shensha[1]='寅';}else if($rig=='乙'){$shensha[0]='子申';$shensha[1]='卯';
    }else if($rig=='丙'){$shensha[0]='亥酉';$shensha[1]='巳';}else if($rig=='丁'){$shensha[0]='亥酉';$shensha[1]='午';
    }else if($rig=='戊'){$shensha[0]='丑未';$shensha[1]='巳';}else if($rig=='己'){$shensha[0]='子申';$shensha[1]='午';
    }else if($rig=='庚'){$shensha[0]='丑未';$shensha[1]='申';}else if($rig=='辛'){$shensha[0]='寅';$shensha[1]='酉';
    }else if($rig=='壬'){$shensha[0]='卯巳';$shensha[1]='亥';}else if($rig=='癸'){$shensha[0]='卯巳';$shensha[1]='子';
    }
    if($riz=='子'||$riz=='辰'||$riz=='申'){$shensha[2]='寅';$shensha[3]='酉';
    }else if($riz=='丑'||$riz=='巳'||$riz=='酉'){$shensha[2]='亥';$shensha[3]='午';
    }else if($riz=='寅'||$riz=='午'||$riz=='戌'){$shensha[2]='申';$shensha[3]='卯';
    }else{$shensha[2]='巳';$shensha[3]='子';
    }
    $GLOBALS['shensha']=$shensha;
}
function zhouyiqigua_year($ymd,$hour){
    $dizhi=array('0','子','丑','寅','卯','辰','巳','午','未','申','酉','戌','亥');//地支
    $arrgua=array('2,2,2','1,1,1','1,1,2','1,2,1','1,2,2','2,1,1','2,1,2','2,2,1');
    $ymdArr=explode('-',$ymd);
    $m=$ymdArr[1]; //月
    $d=$ymdArr[2];//日
    $sguanum=(cookie('ng')+$m+$d)%8;
    $xguanum=($sguanum+$hour)%8;
    $biannum=($sguanum+$xguanum)%6;
    $strgua=' ,'.$arrgua[$sguanum].','.$arrgua[$xguanum];
    $guaxiang=explode(',',$strgua);
    for($i=1;$i<=6;$i++){
        if($i==$biannum){if($guaxiang[$i]==1){$guaxiang[$i]='3';}else{$guaxiang[$i]='4';}}
    }
    $GLOBALS['guaxiang']=$guaxiang;
    return $guaxiang;
}
function zhouyiqigua_number($num1,$num2){
    $arrgua=array('2,2,2','1,1,1','1,1,2','1,2,1','1,2,2','2,1,1','2,1,2','2,2,1');
    $sguanum=$num1%8;
    $xguanum=$num2%8;
    $biannum=($num1+$num2)%6;
    $strgua=' ,'.$arrgua[$sguanum].','.$arrgua[$xguanum];
    $guaxiang=explode(',',$strgua);
    for($i=1;$i<=6;$i++){
        if($i==$biannum){if($guaxiang[$i]==1){$guaxiang[$i]='3';}else{$guaxiang[$i]='4';}}
    }
    return $guaxiang;
}
function yunshi2019($constellation){
    if(S('yunshi2019'.$constellation)){
        $cArr=S('yunshi2019'.$constellation);
    }else{
        $cArr=M()->query("select id,yunshi from tb_constellation_2019 where star='{$constellation}'");
        S('yunshi2019'.$constellation,$cArr,86400);
    }
    return $cArr[0];
}
